/*!
 * \file frlist_node_create.c
 *
 * All Rights Reserved Copyright (C) 2014 broada,Co.,Ltd.\n
 *
 * \version 3.0
 * \author geyh
 * \date 2016/03/31
 *
 */
#include <CUnit/Basic.h>
#include <stdlib.h>

#include "frcomm.h"
#include "frmem.h"
#include "frlist.h"
#include "conntrack.h"
#include "frct_comm.h"

#include "apmtest_comm.h"

static int __suite_init(void)
{

    return 0;
}

static int __suite_cleanup(void)
{

    return 0;
}

static void __case1(void)
{
    Frlist_node *list_node = NULL;
    char *p_data = NULL;

    list_node = frlist_node_create(p_data);

    CU_ASSERT_PTR_NULL(list_node->data);

    frlist_node_data_free(list_node);
    frfree(list_node);

}

static void __case2(void)
{
    Frlist_node *list_node;
    char *p_data = NULL;

    p_data = (char *)frmalloc(1);
    *p_data = '\0';
    list_node = frlist_node_create(p_data);

    CU_ASSERT_TRUE(memcmp(list_node->data,"\0",1) == 0);

    frlist_node_data_free(list_node);

    frfree(list_node);
}

static void __case3(void)
{
    Frlist_node *list_node;
    char *p_data = NULL;

    p_data = (char *)frmalloc(5);
    snprintf(p_data,5,"%s","test");

    list_node = frlist_node_create(p_data);

    CU_ASSERT_STRING_EQUAL(list_node->data,"test");

    frlist_node_data_free(list_node);

    frfree(list_node);

}


int add_suite_frlist_node_create(void)
{
    CU_pSuite pSuite = NULL;

    if ((pSuite = CU_add_suite("frlist frlist_node_create()", __suite_init, __suite_cleanup)) == NULL)
        return FR_FAIL;

    CU_add_test(pSuite, "case1", __case1);
    CU_add_test(pSuite, "case2", __case2);
    CU_add_test(pSuite, "case3", __case3);

    return FR_SUCC;
}
